package com.group4.edu.handler;

import com.study.exceptions.ChapterException;
import com.study.util.ResponseResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Description:
 * @Author:l
 * @Date:2022.03.14
 */
@RestControllerAdvice
public class EduExceptionHandler {
    @ExceptionHandler(ChapterException.class)
    public ResponseResult error(ChapterException e){
        ResponseResult<Object> result = new ResponseResult<>();
        result.setCode(400);
        result.setMessage(e.getMessage());
        result.setData(e);
        return result;
    }
}
